package com.mall.mymall.controller;


import com.mall.mymall.common.Result;
import com.mall.mymall.dao.dto.OrderDetailsDto;
import com.mall.mymall.service.OrderDetailsService;
import com.mall.mymall.service.ProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 十里坡
 * @since 2025-03-06
 */
@RestController
@RequestMapping("/orderDetails")
public class OrderDetailsController {

    @Autowired
    private OrderDetailsService orderDetailsService;

    @GetMapping("/{orderId}")
    public Result<List<OrderDetailsDto>> getOrderDetails(@PathVariable Integer orderId){
        List<OrderDetailsDto> orderDetails = orderDetailsService.getOrderDetails(orderId);
        return orderDetails  == null ? Result.fail("获取订单详情失败") : Result.success(orderDetails);
    }
}

